package com.example.lanouhn.bantangapp.activities.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.lanouhn.bantangapp.R;
import com.example.lanouhn.bantangapp.activities.OnRecycleViewItemClickListenter;
import com.example.lanouhn.bantangapp.activities.contants.Search_deildelist;
import com.example.lanouhn.bantangapp.activities.contants.Search_hottag;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by lanouhn on 16/7/19.
 */
public class Adapter_Activity_hottag extends RecyclerView.Adapter<Adapter_Activity_hottag.MyViewHolder> {
    private Context context;
    List<Search_hottag> list;

    private OnRecycleViewItemClickListenter listenter;

    public void  setOnRecycleViewItemClickListenter(OnRecycleViewItemClickListenter listenter){
        this.listenter=listenter;

    }


    public Adapter_Activity_hottag(Context context, List<Search_hottag> list) {
        this.context = context;
        this.list = list;

    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.hottag_item,null);
        MyViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, final int position) {

        holder.tv.setText(list.get(position).getData());

        //item调用点击

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listenter.OnClick(holder.itemView,position);

            }
        });

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

        private TextView  tv;

        public MyViewHolder(View itemView) {
            super(itemView);
            tv= (TextView) itemView.findViewById(R.id.tv);


        }
    }
}
